﻿<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
	<base th:href="${#request.getContextPath()+'/'}">
<meta charset="utf-8">
<meta name="renderer" content="webkit|ie-comp|ie-stand">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
<!--[if lt IE 9]>
<script type="text/javascript" src="lib/html5shiv.js"></script>
<script type="text/javascript" src="lib/respond.min.js"></script>
<![endif]-->
<link rel="stylesheet" type="text/css" href="h-ui/css/H-ui.min.css" />
<link rel="stylesheet" type="text/css" href="h-ui.admin/css/H-ui.admin.css" />
<link rel="stylesheet" type="text/css" href="lib/Hui-iconfont/1.0.8/iconfont.css" />
<link rel="stylesheet" type="text/css" href="h-ui.admin/skin/default/skin.css" id="skin" />
<link rel="stylesheet" type="text/css" href="h-ui.admin/css/style.css" />
<!--[if IE 6]>
<script type="text/javascript" src="lib/DD_belatedPNG_0.0.8a-min.js" ></script>
<script>DD_belatedPNG.fix('*');</script>
<![endif]-->
<title>用户管理</title>


</head>
<body>
<nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> 首页 <span class="c-gray en">&gt;</span> 用户中心 <span class="c-gray en">&gt;</span> 用户管理 <a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新" ><i class="Hui-iconfont">&#xe68f;</i></a></nav>
<div class="page-container">
	<form action="" method="" class="form form-horizontal" id="likeSelectForm">
		<div class="container">
			<div class="row cl">
				<div class="formControls col-xs-12 col-sm-3">
					<input type="text" class="input-text" placeholder="请输入要搜索的用户姓名" id="likeParam" name="likeParam" datatype="/^[\u4E00-\u9FA5\uf900-\ufa2d]{2,6}$/" nullmsg="搜索信息不能为空" errormsg="请输入用户姓名">
				</div>
				<div class="col-xs-12 col-sm-5">
					<button type="submit" class="btn btn-success radius" id="likeSelectBut" ><i class="Hui-iconfont">&#xe665;</i> 搜索</button>
				</div>
			</div>
		</div>
	</form>
	<div class="cl pd-5 bg-1 bk-gray mt-20">
		<span class="l">
			<a href="javascript:;" onclick="user_selDel()" class="btn btn-danger radius"><i class="Hui-iconfont">&#xe6e2;</i> 批量删除</a>
			<a href="javascript:;" onclick="user_add('添加用户信息','getAddUser','','510')" class="btn btn-primary radius"><i class="Hui-iconfont">&#xe600;</i>添加用户信息</a>
		</span>
		<span class="r">共有数据：<strong th:text="${page.total}">88</strong> 条</span> </div>
	<div class="mt-20">
	<table class="table table-border table-bordered table-hover table-bg table-sort">
		<thead>
			<tr class="text-c">
				<th width="25"><input type="checkbox" id="allSelectBut" name="" value=""></th>
				<th width="80">用户编号</th>
				<th width="100">用户名</th>
				<th width="40">用户昵称</th>
				<th width="90">性别</th>
				<th width="90">邮箱</th>
				<th width="90">创建用户</th>
				<th width="90">创建时间</th>
				<th width="90">修改用户</th>
				<th width="90">修改时间</th>
				<th width="100">操作</th>
			</tr>
		</thead>
		<tbody>
			<tr class="text-c" th:each="user:${page.records}">
				<td><input type="checkbox" th:value="${user.userId}" class="stySelFlag"></td>
				<td th:text="${user.userId}"></td>
				<td th:text="${user.username}"></td>
				<td th:text="${user.password}"></td>
				<td th:text="${user.sex==1}?'女':'男'"></td>
				<td th:text="${user.email}"></td>
				<td th:text="${user.createUser}"></td>
				<td th:text="${#dates.format(user.createTime,'yyyy-MM-dd hh-mm-ss')}"></td>
				<td th:text="${user.updateUser}"></td>
				<td th:text="${#dates.format(user.updateTime,'yyyy-MM-dd hh-mm-ss')}"></td>
				<td class="td-manage">
					<a title="编辑" href="javascript:;" th:onclick="|member_edit('编辑用户信息','user/getEditUser/${user.userId}','4','','510')|" class="ml-5" style="text-decoration:none"><i class="Hui-iconfont">&#xe6df;</i></a>
					<a title="删除" href="javascript:;" th:id="${user.userId}" onclick="user_del(this.id)" class="ml-5" style="text-decoration:none"><i class="Hui-iconfont">&#xe6e2;</i></a></td>
			</tr>
		</tbody>
	</table>
		<div th:include="common/page::pageDivShow"></div>
	</div>

</div>
<!--_footer 作为公共模版分离出去-->
<script type="text/javascript" src="lib/jquery/1.9.1/jquery.min.js"></script>
<script type="text/javascript" src="lib/layer/2.4/layer.js"></script>
<script type="text/javascript" src="h-ui/js/H-ui.min.js"></script>
<script type="text/javascript" src="h-ui.admin/js/H-ui.admin.js"></script> <!--/_footer 作为公共模版分离出去-->

<!--请在下方写此页面业务相关的脚本-->
<script type="text/javascript" src="lib/My97DatePicker/4.8/WdatePicker.js"></script>
<script type="text/javascript" src="lib/datatables/1.10.0/jquery.dataTables.min.js"></script>
<script type="text/javascript" src="lib/laypage/1.2/laypage.js"></script>


<!--validform验证-->
<script type="text/javascript" src="lib/Validform/5.3.2/Validform.min.js"></script>
<script type="text/javascript" src="lib/icheck/jquery.icheck.min.js"></script>


<script type="text/javascript">
/*搜索*/
$(function () {
	$("#likeSelectForm").Validform({
		tiptype:2
		,callback:function(form){ // 表单校验通过后调用这个函数
			console.info("表单校验通过");
			var param=new Object();
			param.sName=$("#likeParam").val();

			var url="user/SelectBysName";
			alert(param.sName)
			$.post(url,param)

			// 如果callback里明确return false，则表单不会提交，如果return true或没有return，则会提交表单
			return false;
		}
	});
})
/*用户-批量删除*/
function user_selDel() {

	var array=new Array();
	/*获取所有选中信息的id*/
	$(".stySelFlag:checked").each(function () {
		var userId=$(this).val();
		array.push(userId)
	})

	if (array==""){
		layer.msg("请选择需要删除的条数",{icon:2,time:2000})
	}else {
		/*创建对象，将需要删除的用户id保存*/
		var param=new Object();
		param.userId=array;

		layer.confirm('确认要删除选中用户信息吗？',function(){
			$.ajax({
				type: 'POST',
				url: 'user/batchDelUser',
				data:param,
				dataType: 'json',
				success: function(data){
					if(data.status=="ok") {
						layer.msg(data.msg, {icon: 1, time: 2000});
						setTimeout(function () {
							location.reload()
						},1000)

					}else {
						layer.msg(data.msg, {icon: 2, time: 2000});

					}
				},
				error:function(data) {
					console.log(data.msg);
				},
			});
		});
	}

}
/*用户-添加*/
function user_add(title,url,w,h){
	layer_show(title,url,w,h);
}

/*用户-编辑*/
function member_edit(title,url,id,w,h){
	layer_show(title,url,w,h);
}

/*用户单个-删除*/
function user_del(id){
	layer.confirm('确认要删除吗？',function(index){
		$.ajax({
			type: 'POST',
			url: 'user/delUser/'+id,
			dataType: 'json',
			success: function(data){
				if(data.status=="ok") {
					layer.msg(data.msg, {icon: 1, time: 2000});
					setTimeout(function () {
						location.reload()
					},1000)
				}else {
					layer.msg(data.msg, {icon: 2, time: 2000});
				}
			},
			error:function(data) {
				console.log(data.msg);
			},
		});		
	});
}

</script>

</body>
</html>